<?php
/**
 * 任务更新
 */

namespace App\Repositories\Task;

use App\Enums\TaskEnum;
use App\Exceptions\BasicException;
use Illuminate\Support\Facades\DB;

class TaskUpdateRepository
{

    // 批量执行更新
    public function batchDealUpdate($userTaskList, $aftDegree)
    {
        $today = date("Y-m-d");
        foreach ($userTaskList as $userTask) {
            if ($userTask->module_id == TaskEnum::TASK_MODULE_NEW_PLAYER) {
                $extraData = $userTask->extra_data;
                if ($extraData && $today >= $extraData['show_date']) {
                    $userTask->updateDegree($aftDegree);
                } elseif ($userTask->type_id == TaskEnum::TASK_TYPE_CREATE_ROOM) { //创建房间进行额外的提前完成，防止出现无法完成问题
                    $userTask->updateDegree($aftDegree);
                }
            } else {
                $userTask->updateDegree($aftDegree);
            }
        }
        return true;
    }

    // 新手每日汇总任务
    public function updateTaskNewPlayerSummary($data)
    {
        if (empty($data['task_id'])) {
            throw new BasicException(15008);
        }

        $curTask = app("model_task_user")->where([
            ["id", "=", $data['task_id']],
            ["is_deleted", "=", 0],
            ["expire_time", ">=", time()]
        ])->first();
        if (empty($curTask)) {
            throw new BasicException(15021);
        }

        $userTask = app("model_task_user")->where([
            ["unique_id", "=", $curTask->parent_unique_id],
            ["is_deleted", "=", 0],
            ["status", "=", TaskEnum::TASK_USER_UN_FINISH],
            ["expire_time", ">=", time()]
        ])->lockForUpdate()->first();

        if (empty($userTask)) {
            return true;
        }

        $afterDegree = app("repo_task")->getAllChildTaskNumber($userTask->unique_id, TaskEnum::TASK_USER_HAS_GET);

        $userTask->updateDegree($afterDegree);

        return true;
    }

    // 新手礼包任务
    public function updateTaskGiftBagType($data)
    {

        if (empty($data['task_id'])) {
            throw new BasicException(15008);
        }

        $curTask = app("model_task_user")->where([
            ["id", "=", $data['task_id']],
            ["is_deleted", "=", 0],
            ["expire_time", ">=", time()]
        ])->first();
        if (empty($curTask)) {
            throw new BasicException(15021);
        }

        if ($curTask->type_id != TaskEnum::TASK_TYPE_NEW_PLAYER_SUMMARY) {
            return true;
        }

        $userTask = app("model_task_user")->where([
            ["is_deleted", "=", 0],
            ["status", "=", TaskEnum::TASK_USER_UN_FINISH],
            ["user_id", "=", $data['user_id']],
            ["type_id", "=", TaskEnum::TASK_TYPE_GIFT_BAG_TYPE],
            ["expire_time", ">=", time()]
        ])->first();

        if (empty($userTask)) {
            return true;
        }

        $res       = app("repo_reward")->getUserProp($data['user_id']);
        $aftDegree = $res['magic_hat'];

        $userTask->updateDegree($aftDegree);

        return true;
    }

    // 累计登录天数
    public function updateTaskSummaryLogin($data)
    {

        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_SUMMARY_LOGIN, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserTotalLoginDays($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 进房累计时长
    public function updateTaskSummaryJoinRoomDelay($data)
    {

        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_SUMMARY_JOIN_ROOM_DELAY, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $delaySeconds = app("repo_user")->getUserStayInRoomDelay($data['user_id']);

        $aftDegree = floor($delaySeconds / 60);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 当日进房累计时长
    public function updateTaskSummaryJoinRoomDailyDelay($data)
    {
        $today             = date("Y-m-d");
        $userTaskList      = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_SUMMARY_JOIN_ROOM_DAILY_DELAY, $data['user_id']);
        $d                 = $data;
        $d['userTaskList'] = $userTaskList;
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }
        $delaySeconds = app("repo_user")->getUserStayInRoomDailyDelay($data['user_id'], $today);
        $aftDegree    = floor($delaySeconds / 60);
        if ($aftDegree < 0) {
            return true;
        }
        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 参与浇水次数
    public function updateTaskPlayWateringTimes($data)
    {

        $userTaskList = app("model_task_user")->where([
            ["is_deleted", "=", 0],
            ["status", "=", TaskEnum::TASK_USER_UN_FINISH],
            ["user_id", "=", $data['user_id']],
            ["type_id", "=", TaskEnum::TASK_TYPE_PLAY_WATERING_TIMES],
            ["expire_time", ">=", time()]
        ])->get();

        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserPlayCatWaterTimes($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 当日参与浇水次数
    public function updateTaskPlayWateringDailyTimes($data)
    {
        $today = date("Y-m-d");

        $userTaskList = app("model_task_user")->where([
            ["is_deleted", "=", 0],
            ["status", "=", TaskEnum::TASK_USER_UN_FINISH],
            ["user_id", "=", $data['user_id']],
            ["type_id", "=", TaskEnum::TASK_TYPE_PLAY_WATERING_DAILY_TIMES],
            ["expire_time", ">=", time()]
        ])->get();

        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserPlayCatWaterDailyTimes($data['user_id'], $today);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 累计分享次数
    public function updateTaskShareTimes($data)
    {

        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_SHARE_TIMES, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserTotalShareTimes($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 关注房间个数
    public function updateTaskFollowRoomNumber($data)
    {

        $userTaskList = app("repo_task")->getUnGetTaskByType(TaskEnum::TASK_TYPE_FOLLOW_ROOM_NUMBER, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserFollowRoomNumber($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 今日关注房间个数
    public function updateTaskFollowRoomDailyNumber($data)
    {
        $today        = date("Y-m-d");
        $userTaskList = app("repo_task")->getUnGetTaskByType(TaskEnum::TASK_TYPE_FOLLOW_ROOM_DAILY_NUMBER, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserFollowRoomDailyNumber($data['user_id'], $today);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 关注用户个数
    public function updateTaskFollowUserNumber($data)
    {

        $userTaskList = app("repo_task")->getUnGetTaskByType(TaskEnum::TASK_TYPE_FOLLOW_USER_NUMBER, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserFollowNumber($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 当日关注用户个数
    public function updateTaskFollowUserDailyNumber($data)
    {
        $today        = date("Y-m-d");
        $userTaskList = app("repo_task")->getUnGetTaskByType(TaskEnum::TASK_TYPE_FOLLOW_USER_DAILY_NUMBER, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserFollowDailyNumber($data['user_id'], $today);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 公屏聊天次数
    public function updateTaskPublicChatTimes($data)
    {

        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_PUBLIC_CHAT_TIMES, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserPublicChatTimes($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 今日聊天次数
    public function updateTaskPublicChatDailyTimes($data)
    {
        $today        = date("Y-m-d");
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_PUBLIC_CHAT_DAILY_TIMES, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserPublicChatDailyTimes($data['user_id'], $today);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 发送表情次数
    public function updateTaskSendFaceTimes($data)
    {
        // 暂时无法区分表情
        return true;
    }

    // 好友个数
    public function updateTaskHasFriendNumber($data)
    {

        $userTaskList = app("repo_task")->getUnGetTaskByType(TaskEnum::TASK_TYPE_HAS_FRIEND_NUMBER, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserFriendNumber($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 今日新增好友个数
    public function updateTaskHasFriendDailyNumber($data)
    {
        $today        = date("Y-m-d");
        $userTaskList = app("repo_task")->getUnGetTaskByType(TaskEnum::TASK_TYPE_HAS_FRIEND_DAILY_NUMBER, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserFriendNumber($data['user_id'], $today);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 赠送礼物次数
    public function updateTaskGiveGiftTimes($data)
    {

        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_GIVE_GIFT_TIMES, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserSendGiftTimes($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 今日赠送礼物次数
    public function updateTaskGiveGiftDailyTimes($data)
    {
        $today        = date("Y-m-d");
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_GIVE_GIFT_DAILY_TIMES, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserSendGiftDailyTimes($data['user_id'], $today);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 收到礼物的价值
    public function updateTaskReceiveGiftMoney($data)
    {

        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_RECEIVE_GIFT_MONEY, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserReceiveGiftValue($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 当日收到礼物的价值
    public function updateTaskReceiveGiftDailyMoney($data)
    {
        $today        = date("Y-m-d");
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_RECEIVE_GIFT_DAILY_MONEY, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserReceiveGiftDailyValue($data['user_id'], $today);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 参与红包雨次数
    public function updateTaskPlayRedPackRainTimes($data)
    {
        // 红包雨声喵暂不上线
        return true;
    }

    // 今日参与红包雨次数
    public function updateTaskPlayRedPackRainDailyTimes($data)
    {
        // 红包雨声喵暂不上线
        return true;
    }

    // 完成实名认证
    public function updateTaskCompleteVerify($data)
    {
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_COMPLETE_VERIFY, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $res = app("repo_user")->isAuth($data['user_id']);

        $aftDegree = intval($res);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 设置个性签名
    public function updateTaskSetPersonSign($data)
    {

        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_SET_PERSON_SIGN, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $res = app("repo_user")->isSetSign($data['user_id']);

        $aftDegree = intval($res);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 创建房间
    public function updateTaskCreateRoom($data)
    {
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_CREATE_ROOM, $data['user_id']);

        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $res = app("repo_user")->isCreateRoom($data['user_id']);

        $aftDegree = intval($res);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 充值次数
    public function updateTaskRechargeTimes($data)
    {
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_RECHARGE_TIMES, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserRechargeTimes($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 今日充值次数
    public function updateTaskRechargeDailyTimes($data)
    {
        $today        = date("Y-m-d");
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_RECHARGE_DAILY_TIMES, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserRechargeDailyTimes($data['user_id'], $today);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 充值金额
    public function updateTaskRechargeMoney($data)
    {
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_RECHARGE_TIMES, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserRechargeMoney($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 今日充值金额
    public function updateTaskRechargeDailyMoney($data)
    {
        $date         = date("Y-m-d");
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_RECHARGE_DAILY_MONEY, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserRechargeDailyMoney($data['user_id'], $date);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 进入房间个数
    public function updateTaskEnterDiffRoomNumber($data)
    {
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_ENTER_DIFF_ROOM_NUMBER, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserEnterRoomNumber($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 当日进入房间个数
    public function updateTaskEnterDiffRoomDailyNumber($data)
    {
        $today        = date("Y-m-d");
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_ENTER_DIFF_ROOM_DAILY_NUMBER, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserEnterRoomDailyNumber($data['user_id'], $today);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 参与抢糖果次数
    public function updateTaskRedEnvelopeTimes($data)
    {
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_RED_ENVELOPE_TIMES, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserPlayCandyTimes($data['user_id']);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 今日参与抢糖果次数
    public function updateTaskRedEnvelopeDailyTimes($data)
    {
        $today        = date("Y-m-d");
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_RED_ENVELOPE_DAILY_TIMES, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserPlayCandyDailyTimes($data['user_id'], $today);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 邀请好友次数
    public function updateTaskInviteFriendTimes($data)
    {
        $user = app("model_user")->where("user_id", $data['user_id'])->first();
        if (empty($user)) {
            throw new BasicException(15003);
        }
        $parentId = $user->parent_id;
        if (empty($parentId)) {
            return true;
        }

        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_INVITE_FRIEND_TIMES, $parentId);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserInviteTimes($parentId);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 当日邀请好友次数
    public function updateTaskInviteFriendDailyTimes($data)
    {
        $user = app("model_user")->where("user_id", $data['user_id'])->first();
        if (empty($user)) {
            throw new BasicException(15003);
        }
        $parentId = $user->parent_id;
        if (empty($parentId)) {
            return true;
        }

        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_INVITE_FRIEND_DAILY_TIMES, $parentId);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $today     = date("Y-m-d");
        $aftDegree = app("repo_user")->getUserInviteDailyTimes($parentId, $today);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 今日积分商城兑换次数
    public function updateTaskIntegralExchangeDailyTimes($data)
    {
        $today        = date("Y-m-d");
        $userTaskList = app("repo_task")->getUnFinishTaskByType(TaskEnum::TASK_TYPE_INTEGRAL_EXCHANGE_DAILY_TIMES, $data['user_id']);
        if (empty($userTaskList) || count($userTaskList) == 0) {
            return true;
        }

        $aftDegree = app("repo_user")->getUserScoreMallExchangeDailyTimes($data['user_id'], $today);

        return $this->batchDealUpdate($userTaskList, $aftDegree);
    }

    // 今日礼盒兑换次数
    public function updateTaskBoxExchangeDailyTimes($data)
    {
        // 礼盒尚未实现

        return true;
    }


    // 更新任务进度
    public function updateTaskDegree($taskTypeArr, $data)
    {
        if (empty($data['user_id'])) {
            throw new BasicException(15010);
        }
        DB::connection("mysql")->transaction(function () use ($taskTypeArr, $data) {
            foreach ($taskTypeArr as $taskType) {
                switch ($taskType) {
                    case TaskEnum::TASK_TYPE_NEW_PLAYER_SUMMARY:
                        $result = $this->updateTaskNewPlayerSummary($data);
                        break;
                    case TaskEnum::TASK_TYPE_GIFT_BAG_TYPE:
                        $result = $this->updateTaskGiftBagType($data);
                        break;
                    case TaskEnum::TASK_TYPE_SUMMARY_LOGIN:
                        $result = $this->updateTaskSummaryLogin($data);
                        break;
                    case TaskEnum::TASK_TYPE_SUMMARY_JOIN_ROOM_DELAY:
                        $result = $this->updateTaskSummaryJoinRoomDelay($data);
                        break;
                    case TaskEnum::TASK_TYPE_SUMMARY_JOIN_ROOM_DAILY_DELAY:
                        $result = $this->updateTaskSummaryJoinRoomDailyDelay($data);
                        break;
                    case TaskEnum::TASK_TYPE_PLAY_WATERING_TIMES:
                        $result = $this->updateTaskPlayWateringTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_PLAY_WATERING_DAILY_TIMES:
                        $result = $this->updateTaskPlayWateringDailyTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_SHARE_TIMES:
                        $result = $this->updateTaskShareTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_FOLLOW_ROOM_NUMBER:
                        $result = $this->updateTaskFollowRoomNumber($data);
                        break;
                    case TaskEnum::TASK_TYPE_FOLLOW_ROOM_DAILY_NUMBER:
                        $result = $this->updateTaskFollowRoomDailyNumber($data);
                        break;
                    case TaskEnum::TASK_TYPE_FOLLOW_USER_NUMBER:
                        $result = $this->updateTaskFollowUserNumber($data);
                        break;
                    case TaskEnum::TASK_TYPE_FOLLOW_USER_DAILY_NUMBER:
                        $result = $this->updateTaskFollowUserDailyNumber($data);
                        break;
                    case TaskEnum::TASK_TYPE_PUBLIC_CHAT_TIMES:
                        $result = $this->updateTaskPublicChatTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_PUBLIC_CHAT_DAILY_TIMES:
                        $result = $this->updateTaskPublicChatDailyTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_SEND_FACE_TIMES:
                        $result = $this->updateTaskSendFaceTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_HAS_FRIEND_NUMBER:
                        $result = $this->updateTaskHasFriendNumber($data);
                        break;
                    case TaskEnum::TASK_TYPE_HAS_FRIEND_DAILY_NUMBER:
                        $result = $this->updateTaskHasFriendDailyNumber($data);
                        break;
                    case TaskEnum::TASK_TYPE_GIVE_GIFT_TIMES:
                        $result = $this->updateTaskGiveGiftTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_GIVE_GIFT_DAILY_TIMES:
                        $result = $this->updateTaskGiveGiftDailyTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_RECEIVE_GIFT_MONEY:
                        $result = $this->updateTaskReceiveGiftMoney($data);
                        break;
                    case TaskEnum::TASK_TYPE_RECEIVE_GIFT_DAILY_MONEY:
                        $result = $this->updateTaskReceiveGiftDailyMoney($data);
                        break;
                    case TaskEnum::TASK_TYPE_PLAY_RED_PACK_RAIN_TIMES:
                        $result = $this->updateTaskPlayRedPackRainTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_PLAY_RED_PACK_RAIN_DAILY_TIMES:
                        $result = $this->updateTaskPlayRedPackRainDailyTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_COMPLETE_VERIFY:
                        $result = $this->updateTaskCompleteVerify($data);
                        break;
                    case TaskEnum::TASK_TYPE_SET_PERSON_SIGN:
                        $result = $this->updateTaskSetPersonSign($data);
                        break;
                    case TaskEnum::TASK_TYPE_CREATE_ROOM:
                        $result = $this->updateTaskCreateRoom($data);
                        break;
                    case TaskEnum::TASK_TYPE_RECHARGE_TIMES:
                        $result = $this->updateTaskRechargeTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_RECHARGE_DAILY_TIMES:
                        $result = $this->updateTaskRechargeDailyTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_RECHARGE_MONEY:
                        $result = $this->updateTaskRechargeMoney($data);
                        break;
                    case TaskEnum::TASK_TYPE_RECHARGE_DAILY_MONEY:
                        $result = $this->updateTaskRechargeDailyMoney($data);
                        break;
                    case TaskEnum::TASK_TYPE_ENTER_DIFF_ROOM_NUMBER:
                        $result = $this->updateTaskEnterDiffRoomNumber($data);
                        break;
                    case TaskEnum::TASK_TYPE_ENTER_DIFF_ROOM_DAILY_NUMBER:
                        $result = $this->updateTaskEnterDiffRoomDailyNumber($data);
                        break;
                    case TaskEnum::TASK_TYPE_RED_ENVELOPE_TIMES:
                        $result = $this->updateTaskRedEnvelopeTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_RED_ENVELOPE_DAILY_TIMES:
                        $result = $this->updateTaskRedEnvelopeDailyTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_INVITE_FRIEND_TIMES:
                        $result = $this->updateTaskInviteFriendTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_INVITE_FRIEND_DAILY_TIMES:
                        $result = $this->updateTaskInviteFriendDailyTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_BOX_EXCHANGE_DAILY_TIMES:
                        $result = $this->updateTaskBoxExchangeDailyTimes($data);
                        break;
                    case TaskEnum::TASK_TYPE_INTEGRAL_EXCHANGE_DAILY_TIMES:
                        $result = $this->updateTaskIntegralExchangeDailyTimes($data);
                        break;
                    default:
                        throw new BasicException(15007);
                }

                if (!$result) {
                    throw new BasicException(15015);
                }
            }
        }, 3);

        return true;
    }

}
